<?php

namespace App\Library\Service;

use App\Library\Logic\NotifyLogic;
use Psr\Http\Message\ResponseInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\InvalidParamsException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;

class AlipayService extends BaseService
{
    /**
     * notify
     * @return ResponseInterface
     * @throws ContainerException
     * @throws InvalidParamsException
     */
    public function notify(): ResponseInterface
    {
        $result = Pay::alipay()->callback(request()->post());
        NotifyLogic::insertForModel('result', $result);
        return Pay::alipay()->success();
    }
}
